package com.android.bookgarden.ui;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.android.bookgarden.R;
import com.android.bookgarden.base.BaseActivity;
import com.android.bookgarden.views.InputPassWordLinearLayout;
import com.android.bookgarden.views.KeyboardPasswordLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Create by zouqh
 * on 2018/12/4
 **/
public class InputPayPassWordActivity extends BaseActivity implements View.OnClickListener {
    @BindView(R.id.cancel)
    TextView cancel;
    @BindView(R.id.passLine)
    InputPassWordLinearLayout passLine;
    @BindView(R.id.next)
    TextView next;
    @BindView(R.id.keyboard)
    KeyboardPasswordLayout keyboard;

    private List<String> list;

    @Override
    protected int getLayoutId() {
        return R.layout.input_pay_password;
    }

    @Override
    protected void initView() {
        list = new ArrayList<>();
        cancel.setOnClickListener(this);
        keyboard.setClickListener(new KeyboardPasswordLayout.KeyboardOnClickListener() {
            @Override
            public void inputPass(String number) {
                Log.e("number----",number);
                if (list.size()<6){
                    list.add(number);
                    passLine.setPass(list);
                }
            }

            @Override
            public void deletePass() {
                if (list.size()>0){
                    list.remove(list.size()-1);
                    if (list.size()==0){
                        passLine.setPass(null);
                    }else{
                        passLine.setPass(list);
                    }

                }
            }
        });
    }

    @Override
    public void onRequestPermissions(String str, boolean z) {

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.cancel:
                finish();
                break;
        }
    }


}
